package com.taotao.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taotao.comm.pojo.EasyUIDataGridResult;
import com.taotao.comm.pojo.EasyUITreeNode;
import com.taotao.context.service.ContentCategoryService;
import com.taotao.pojo.TbContentCategory;
import com.taotao.utils.TaotaoResult;

@Controller
@RequestMapping("/content/category")
public class ContentCategoryController {
	@Autowired
	private ContentCategoryService contentCategoryService;
	
	@RequestMapping("/list")
	@ResponseBody
	public List<EasyUITreeNode> contentCategoryList(@RequestParam(defaultValue="0",value="id")long pid){
		List<EasyUITreeNode> list = contentCategoryService.getContentCategoryNode(pid);
		return list;
	}
	
	
	@RequestMapping("/create")
	@ResponseBody
	public TaotaoResult createCategory(@RequestParam("parentId")long pid,String name){
		TaotaoResult result = contentCategoryService.insertCategory(pid, name);
		
		return result;
	} 
	
	@RequestMapping("/delete")
	@ResponseBody
	public TaotaoResult deleteCategory(long id){
		TaotaoResult result = contentCategoryService.deleteCategory(id);
		return result;
	}
	
	@RequestMapping("/update")
	@ResponseBody
	public TaotaoResult update(long id,String name){
		TaotaoResult result = contentCategoryService.updateCategory(id, name);
		return result;
	}
}
